package com.singleton.demo06;
/**
 * 序列键生成器 采用单例模式
 */
public class KeyGenerator {
    private static KeyGenerator instance = new KeyGenerator();
    private KeyGenerator(){
        key = new KeyInfo(POOL_SIZE);
    }
    public static KeyGenerator getInstance(){
        return instance;
    }
    private static final int POOL_SIZE = 20;

    private KeyInfo key;

    public int getKey(){
        return key.getNextKey();
    }
}
